<?php

/**
 * @author Terry & 千里孤坟
 * @copyright 2009
 */

class SpecStatus {
	public function __construct(){
		$this->id = -1;
		$this->on = 0;		//开关
		$this->name = "基类";
		$this->time = 0;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a) {				
		return 0;
	}
	
	public function cancel($a) {
		$a->spec_status[$this->id]->on = 0;
		$a->spec_status[$this->id]->n = 0;
	}		
}

class Hungry extends SpecStatus {

	public function __construct(){
		$this->id = 1;
		$this->on = 0;		//开关
		$this->name = "饥饿";
		$this->time = 999;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a) {
		if($a->hp > 0) {
			$this->n++;						
			$a->hp -= 50;
			$a->sp -= 50;
			$a->tp -= 50;
			$_SESSION['show'] .= $a->name."饥饿中(第".$this->n."次)，hp/sp/tp减少。<br>";
			if($a->eventskill_status[3]->on == 1) {
				$a->eventskill_status[3]->action($a);
			}
		}
		
		if($a->sp < 0) $a->sp = 0;
		if($a->tp < 0) $a->tp = 0;
		if($a->hp < 0) {
			$a->hp = 0;
			$this->cancel($a);
			$_SESSION['show'] .= "受到经济危机的影响，".$a->name."活活饿死了。<br>";
			StatusHelper::resetall($a);
			return 1;	
		}
		
		return 0;						
	}
}

//瘟疫效果

class Plagues extends SpecStatus {

	public function __construct(){
		$this->id = 2;
		$this->on = 0;		//开关
		$this->name = "瘟疫";
		$this->time = 999;	//持续回合数，999即作为永久
		$this->n = 0;		//当前进行次数
	}
	
	public function action($a) {

		if($a->spec_status[$this->id]->n == 0){
			$this->downstr = 0;
			$this->downmgr = 0;
			$this->downspd = 0;
			$this->downvit = 0;
		}

		$this->n++;
		if($a->hp > 0) {
			if($a->str-5>0) {
				$a->str -= 5;
				$this->downstr += 5;
			} else {
				$a->str = 0;
				$this->downstr += $a->str;
			}

			if($a->mgr-5>0) {
				$a->mgr -= 5;
				$this->downmgr += 5;
			} else {
				$a->mgr = 0;
				$this->downmgr += $a->mgr;
			}

			if($a->spd-5>0) {
				$a->spd -= 5;
				$this->downspd += 5;
			} else {
				$a->spd = 0;
				$this->downspd += $a->spd;
			}

			if($a->vit-5>0) {
				$a->vit -= 5;
				$this->downvit += 5;
			} else {
				$a->vit = 0;
				$this->downvit += $a->vit;
			}

			$_SESSION['show'] .= $a->name."瘟疫中(第".$this->n."次)，身心逐渐腐蚀。<br>";
		}
		
		return 0;						
	}

		public function cancel($a) {
			$a->spec_status[$this->id]->on = 0;
			$a->spec_status[$this->id]->n = 0;
			$a->str += $this->downstr;
			$a->mgr += $this->downmgr;
			$a->spd += $this->downspd;
			$a->vit += $this->downvit;
		}
}

?>
